// ts中如何定义类
namespace b {
    class Person {
        name: string = '雷超'; // 这个是实例的属性
        age: number = 26;
        constructor(age?: any, name?: any) {
            // this.age = age
            // this.name = name
        }
    }
    let p1 = new Person()
    console.log(p1)
}
namespace a {
    class Person {
        myname: string;
        constructor(myname: string) {
            this.myname = myname;
        }
        set name(newVal: string) {
            this.myname = newVal.toLocaleUpperCase()
        }
        get name(): string {
            return this.myname
        }
    }
    let p = new Person('吴鹏丽abcdefg')
    p.name = 'abcdefg'
    console.log(p.name)
}
namespace c {
    class Person {
        // myname: string;
        // public关键字的作用就是上面和下面的集合
        constructor(public myname: string) {
            // this.myname = myname;
        }
        set name(newVal: string) {
            this.myname = newVal.toLocaleUpperCase()
        }
        get name(): string {
            return this.myname
        }
    }
    let p = new Person('吴鹏丽abcdefg')
}
// 继承
/**
 * 子类继承父类
 * 访问修饰符 public, private protected
 */
namespace d {
    class Parent {
        public name: string;
        protected age: string;
        constructor(name: string, age: string) {
            this.name = name;
            this.age = age;
        }
        getName() {
            return this.name
        }
        setName(name: string) {
            this.name = name
        }
    }
    class Children extends Parent {
        stuNo: number;
        constructor(name: string, age: string, stuNo: number) {
            super(name, age)
            this.stuNo = stuNo
        }
        getStuNo() {
            return this.stuNo
        }
        setStuNo(stuNo: number) {
            this.stuNo = stuNo
        }
        public getHa () {
            return this.stuNo
        }
    }
    let p = new Parent('雷超','28')
    let c1 = new Children('小超','12',111)
    console.log(c1.getHa())
}